package com.wanyin.cloud.sentinel.api;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("sentinel")
public class SentinelInfoApi {

    @Service
    public class TestService {

        @SentinelResource(value = "sayHello")
        public String sayHello(String name) {
            return "sentinel hello " + name + " " + LocalDateTime.now();
        }
    }

    @Autowired
    private TestService service;

    @GetMapping("hello")
    public String helloSentinel() {
        return service.sayHello("test");
    }
}
